package cn.wch.blelib.peripheral.callback;

import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothGattCharacteristic;
import android.bluetooth.BluetoothGattDescriptor;

/**
 * BLE服务回调接口
 */
public interface BLEServerCallback {
    /**
     * 连接
     * @param device
     */
    void onConnected(BluetoothDevice device);

    /**
     * 打开连接
     * @param device
     */
    void onDisconnected(BluetoothDevice device);

    /**
     * 特征读取请求
     * @param device
     * @param requestId
     * @param offset
     * @param characteristic
     */
    void onCharacteristicReadRequest(BluetoothDevice device, int requestId, int offset, BluetoothGattCharacteristic characteristic);

    /**
     * 特征写请求
     * @param device
     * @param requestId
     * @param characteristic
     * @param preparedWrite
     * @param responseNeeded
     * @param offset
     * @param value
     */
    void onCharacteristicWriteRequest(BluetoothDevice device, int requestId, BluetoothGattCharacteristic characteristic, boolean preparedWrite, boolean responseNeeded, int offset, byte[] value);

    /**
     * 描述符读取请求
     * @param device
     * @param requestId
     * @param offset
     * @param descriptor
     */
    void onDescriptorReadRequest(BluetoothDevice device, int requestId, int offset, BluetoothGattDescriptor descriptor);

    /**
     * 描述符写取请求
     * @param device
     * @param requestId
     * @param descriptor
     * @param preparedWrite
     * @param responseNeeded
     * @param offset
     * @param value
     */
    void onDescriptorWriteRequest(final BluetoothDevice device, int requestId, BluetoothGattDescriptor descriptor, boolean preparedWrite, boolean responseNeeded, int offset, byte[] value);

    /**
     * Mtu改变
     * @param device
     * @param mtu
     */
    void onMtuChanged(BluetoothDevice device, int mtu);

}
